-------------------------------------------------------------------------------
-- Title: Mik's Scrolling Battle Text Shared Media Support
-- Author: Mik
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
-- Private variables.
-------------------------------------------------------------------------------

local SML = LibStub("LibSharedMedia-3.0");


-------------------------------------------------------------------------------
-- Load.
-------------------------------------------------------------------------------

-- Register a callback with shared media to keep MSBT synced.
SML:RegisterCallback("LibSharedMedia_Registered", 
 function (event, mediaType, name)
  if (mediaType == "font") then
   MikSBT.RegisterFont(name, SML:Fetch(mediaType, name));
  elseif (mediaType == "sound" and MikSBT.RegisterSound) then
   MikSBT.RegisterSound(name, SML:Fetch(mediaType, name));
  end 
 end
);

-- Register the currently available fonts in shared media with MSBT.
for index, fontName in pairs(SML:List("font")) do
 MikSBT.RegisterFont(fontName, SML:Fetch("font", fontName));
end

-- Register the currently available sounds in shared media with MSBT.
if (MikSBT.RegisterSound) then
 for index, soundName in pairs(SML:List("sound")) do
  MikSBT.RegisterSound(soundName, SML:Fetch("sound", soundName));
 end
end